using System;
using System.Windows;
using System.Windows.Interactivity;
namespace Microsoft.Expression.Interactivity.Core
{
	public class PropertyChangedTrigger : TriggerBase<DependencyObject>
	{
		public static readonly DependencyProperty BindingProperty = DependencyProperty.Register("Binding", typeof(object), typeof(PropertyChangedTrigger), new PropertyMetadata(new PropertyChangedCallback(PropertyChangedTrigger.OnBindingChanged)));
		public object Binding
		{
			get
			{
				return base.GetValue(PropertyChangedTrigger.BindingProperty);
			}
			set
			{
				base.SetValue(PropertyChangedTrigger.BindingProperty, value);
			}
		}
		protected virtual void EvaluateBindingChange(object args)
		{
			base.InvokeActions(args);
		}
		protected override void OnAttached()
		{
			base.OnAttached();
			base.PreviewInvoke += new EventHandler<PreviewInvokeEventArgs>(this.OnPreviewInvoke);
		}
		protected override void OnDetaching()
		{
			base.PreviewInvoke -= new EventHandler<PreviewInvokeEventArgs>(this.OnPreviewInvoke);
			this.OnDetaching();
		}
		private void OnPreviewInvoke(object sender, PreviewInvokeEventArgs e)
		{
			DataBindingHelper.EnsureDataBindingOnActionsUpToDate(this);
		}
		private static void OnBindingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
		{
			PropertyChangedTrigger propertyChangedTrigger = (PropertyChangedTrigger)sender;
			propertyChangedTrigger.EvaluateBindingChange(args);
		}
	}
}
